Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADR-32: Logical permissions #145

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

ADR-32: Logical permissions #145

wants to merge 2 commits into from

Conversation

bruth
Copy link
Member

@bruth bruth commented Aug 12, 2022

No description provided.

Signed-off-by: Byron Ruth <b@devel.io>
Signed-off-by: Byron Ruth <b@devel.io>
allow: [
"inbox(operator)",
"js-stream-operator(EVENTS)",
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also need to cover how this maps to the imports and export syntax while we are at it, sub represent either a stream or service.
Like being able to define that reading info about consumer and streams is ok from the other account but not ok to create, something like:

  exports: [{stream: "foo"}, { jetstream: { streams: [ { name: EVENTS, export: [stream-info, consumer-info] }]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Fundamentally, these permissions can be thought of as functions that expand to one or more subjects js-stream-info(EVENTS)$JS.API.STREAM.INFO.EVENTS. I thought about having these permissions able to be intermingled with standard subjects. If that is the case, the ambiguity of subject vs perm needs to be removed, so some kind of prefix character could help differentiate, such as @ or whatever.

Then you could have something like:

exports: [
  {service: "@js-stream-info(EVENTS)"},
]

The implicit pub/sub information would really only apply in the user permissions context.

adr/ADR-32.md Show resolved Hide resolved
allow: [
"inbox(joe)",
"pub(services.*)",
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this syntax is nice, I was thinking of granular permission like below but seems very verbose:

    permissions = {
      # Can publish to stream
      publish: { allow = ["a"] } 

      # Granual permissions for JetStream features
      jetstream: {
        streams { EVENTS = { allow: [ stream-info ], deny: [add-stream, delete-stream] } }
        kv { TEST = { allow: [ put, del], deny: [ destroy-kv ] }
        object-store { allow: [...] }
      }
    }
   }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the structure that your example provides which provides namespacing (as I am doing js- and kv-). A future state I considered was user-defined permissions which may break the structure. For example, if a new key called roles within an account is defined, you could declare new mappings off the primitive logical permissions the NATS server provides.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to subset keys/object names on kv/object store - currently object store doesn't expose data chunks in a way that can be clamped.

@bruth bruth changed the title Draft logical permissions ADR-32: Logical permissions Aug 15, 2022
@MauriceVanVeen
Copy link

Looks really cool! Decouples the configuration from the concrete subjects.

What I'm wondering, how would this work for consuming a stream/watching a KV?

I'm thinking that would be a combination of several permissions, for example:

js-create-ephemeral-consumer
js-consumer-next-msg
js-consumer-ack-reply
etc.

However, that would still require you to know the relationship between multiple permissions, as those need to be combined in order to: create an ephemeral consumer, start consuming from it, and maybe at some point delete the consumer, etc.

I like the syntax of @wallyqs as well, albeit a bit more verbose, it might be more concise with the addition of watching a stream for example:

    permissions = {
      jetstream: {
        streams { EVENTS = { allow: [ watch-ephemeral ] }}
      }
    }

With a short-hand like watch-ephemeral it might combine the ability to both create and delete an ephemeral consumer, as well as receive messages from it, handle heart beats/flow control, etc. This could make a leaf node scenario quite easy as well, just add a watch-ephemeral add a sourced stream on the leaf node and you're off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants